package com.example.quartz.demo.controller;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.example.quartz.demo.QuartzManagerService;
import com.example.quartz.demo.job.HelloJob;
import com.example.quartz.demo.job.SyHelloJob;
import com.example.quartz.demo.job.TestJob;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


@Controller
@RequestMapping("/task")
public class JobController {

	@Autowired
	private QuartzManagerService quartzManagerService;

	@RequestMapping(value = "/start1", method = { RequestMethod.GET })
	@ResponseBody
	public String schedule1()throws Exception
	{
		quartzManagerService.addJob(SyHelloJob.class,"job1","jobgroup1","trigger1","/5 * * * * ?");
         return  "ok1";
	}


	@RequestMapping(value = "/start2", method = { RequestMethod.GET })
	@ResponseBody
	public String schedule2()throws Exception
	{
		quartzManagerService.addJob(HelloJob.class,"job2","jobgroup2","trigger2","/10 * * * * ?");
		return  "ok2";
	}

	@RequestMapping(value = "/start3", method = { RequestMethod.GET })
	@ResponseBody
	public String schedule3()throws Exception
	{
		quartzManagerService.addJob(TestJob.class,"job3","jobgroup3","trigger3","/15 * * * * ?");
		return  "ok3";
	}

}
